﻿Imports Mystery


Public Class SingleEventView

    Private _content_guid As Guid
    Private _event_guid As Guid

    Public Sub New(myEvent As UserEvent)
        InitializeComponent()

        _event_guid = myEvent.guid

        If Not String.IsNullOrEmpty(myEvent.title.value) Then
            myLabel.Content = myEvent.title.value
        End If

        If myEvent.content.value IsNot Nothing Then
            Dim content As IContent = myEvent.content.value
            _content_guid = content.guid
            Dim rt As ReferenceText = content.GetType.getFirstAttribute(Of ReferenceText)()
            Me.ToolTip = rt.getReferenceText(content)
        End If

        If myEvent.event_type = UserEventTypes.important Then
            Dim bit As BitmapImage = New BitmapImage(New Uri("/MysteryControls;component/Images/Crystal_important.png", UriKind.RelativeOrAbsolute))
            myImage.Source = bit
        End If

    End Sub


    Private Sub mybutton_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles mybutton.Click
        Dim cd As IContentDispatcher = getGlobalObject(Of IContentDispatcher)()
        Dim myevent As UserEvent = cd.getContent(Of UserEvent)(_event_guid)
        If myevent Is Nothing Then Exit Sub

        Dim event_details As New EventDetails(myevent)
        Dim w As Window = event_details.instanceWindow()


        AddHandler event_details.done, Sub()
                                           w.Close()
                                       End Sub

        AddHandler event_details.done, Sub()
                                           w.Close()
                                       End Sub

        w.ShowDialog()

    End Sub
End Class
